<?php
if(!defined('NO_LOGIN_CHECK'))
{
	if(!isset($_SESSION["username2"]) || $_SESSION["username2"]==""){
//	echo "<script>alert('您沒有訪問權限，請先登入!');window.open('index.php','_top');</script>";
	header("Location:index.php");
	exit();
	}
	
	if(!defined('PAGE_NEED_PRI'))
	{
		exit("bad access");
	}
	if('UPLOAD_FILE' === constant('PAGE_NEED_PRI') )
	{
		if($_SESSION['PRI_EDIT'] != '1' && $_SESSION['PRI_ADMIN'] != '1' && $_SESSION['PRI_SALE'] != '1')
		{
			exit("don't allowed to access");
		}
	}else if('CHANGEPASSWORD' === constant('PAGE_NEED_PRI') ){
		if($_SESSION['PRI_EDIT'] != '1' && $_SESSION['PRI_ADMIN'] != '1' && $_SESSION['PRI_SALE'] != '1')
		{
			exit("don't allowed to access");
		}
	}else{
	
		if($_SESSION[PAGE_NEED_PRI] != '1' && $_SESSION['PRI_ADMIN'] != '1')
		{
			exit("don't allowed to access");
		}
	}
}
/*
if($_SESSION["username2"]!="522229198307133216" ){
		$sql=mysql_query("select * from guanli where username = '".$_SESSION["username2"]."'   ");
		$result=mysql_fetch_array($sql);
		if ($result==false){
			echo $sql."kdk";
			exit();
			echo "<script>alert('您沒有訪問權限，請先登入!');window.open('index.php','_top');</script>";
		}
}*/
?>